package com.ss.ttvideoengine.b;

import android.text.TextUtils;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public final class VideoItem {
    public String[] videoUrls;
    public String mainUrl;
    public String backupUrl1;
    public String backupUrl2;
    public String backupUrl3;
    public int videoWidth;
    public int videoHeight;
    public String definition;
    public int videoDuration = 0;
    public int preloadInterval = 0;

    public final void initWithJO(JSONObject jo) {
        ArrayList<String> list = new ArrayList();
        this.mainUrl = jo.optString("main_url");
        this.backupUrl1 = jo.optString("backup_url_1");
        this.backupUrl2 = jo.optString("backup_url_2");
        this.backupUrl3 = jo.optString("backup_url_3");
        if (!TextUtils.isEmpty(this.mainUrl)) {
            list.add(android.support.design.a.base64Decode(this.mainUrl));
        }

        if (!TextUtils.isEmpty(this.backupUrl1)) {
            list.add(android.support.design.a.base64Decode(this.backupUrl1));
        }

        if (!TextUtils.isEmpty(this.backupUrl2)) {
            list.add(android.support.design.a.base64Decode(this.backupUrl2));
        }

        if (!TextUtils.isEmpty(this.backupUrl3)) {
            list.add(android.support.design.a.base64Decode(this.backupUrl3));
        }

        this.videoUrls = new String[list.size()];
        list.toArray(this.videoUrls);
        try {
            this.videoWidth = Integer.valueOf(jo.optString("vwidth")).intValue();
        } catch (NumberFormatException v0_1) {
            this.videoWidth = 0;
        }

        try {
            this.videoHeight = Integer.valueOf(jo.optString("vheight")).intValue();
        } catch (NumberFormatException e) {
            this.videoHeight = 0;
        }

        jo.optInt("gbr");
        jo.optString("storePath");
        jo.optString("vtype");
        this.definition = jo.optString("definition");
        try {
            jo.optLong("size", 0);
        } catch (Exception exception) {
        }

        jo.optInt("preload_size");
        jo.optInt("play_load_min_step");
        jo.optInt("play_load_max_step");
        this.preloadInterval = jo.optInt("preload_interval", -1);
        jo.optInt("use_video_proxy", 1);
        jo.optInt("socket_buffer", 0);
    }
}

